<template>
  <div class="hiddentext">
    <textarea name="" id="" cols="60" rows="3"
    v-model="replytext">
    </textarea>
    <button
    @click="handlereply">
        submit
    </button>
  </div>
</template>

<script>
export default {
  name: 'Content',
  props: ['preId'],
  data () {
    return {
      replytext: '',
      newcomment: {
        id: Math.random(),
        name: 'yaoyao',
        time: ' 0 minutes ago',
        isShow: true,
        showtext: false,
        text: '',
        children: []
      }
    }
  },
  methods: {
    getId () {
      let date = Date.now()
      let rund = Math.ceil(Math.random() * 1000)
      let id = date + '' + rund
      return id
    },
    handlereply () {
      this.newcomment.preId = this.preId
      this.newcomment.text = this.replytext
      this.newcomment.id = this.newcomment.id + this.newcomment.name + this.getId()
      this.$store.commit('addComment', this.newcomment)
      this.replytext = ''
      this.$emit('handleAddComment')
    }
  }
}
</script>

<style scoped>
textarea{
    display: block;
}
button{
    margin: 8px 0;
}
</style>
